﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using RTracker.Models.User;

namespace RTracker
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {

            Application["Name"] = "R-Tracker Desktop Browser app";

            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterAuth();
        }


        protected void Session_Start(object sender, EventArgs e)
        {
            //HttpContext currentContext = HttpContext.Current;
            System.Web.HttpBrowserCapabilities myBrowser = new System.Web.HttpBrowserCapabilities();
            myBrowser = System.Web.HttpContext.Current.Request.Browser;

            //Get list of all the users and store it in application user list
            MUser oMUser = new MUser();
            List<CUser> temp_userList = new List<CUser>();
            oMUser.GetAllUserList(out temp_userList);
            Application["UsersList"] = temp_userList;

            Application["Browser"] = myBrowser.Type.ToString();
            Application["OS"] = myBrowser.Platform.ToString();
            Application["Location"] = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
            Application["IpAddress"] = System.Web.HttpContext.Current.Request.UserHostAddress.ToString();

        }


    }
}